#ifndef WINDOW_H
#define WINDOW_H

#include <QtGui>
#include <vector>
#include <iostream>
#include "output.h"
#include "glwidget.h"

class Window : public QMainWindow{
	Q_OBJECT

	public:
		Window();
		~Window();

    signals:
        void onlyOctreeMode(bool);

    private slots:
        void newScene();
        void openObjects();
        void openSceneObjects();
        void openSceneOctrees();
        void saveSceneObjects();
        void saveSceneObjectsAs();
        void saveSceneOctrees();

        void changeSelection();
        void redoOctree(std::vector<Object *>);
        void redoOctree(Object *);
        void rotateOctree(Object *, int, int, int);

//        void editObjectDialog();
        void editObjectDialog(QTreeWidgetItem *, int);
        void deleteObject();
        void analyzeObject();
        void addPrimitive(Object *);
        void newCuboidPrimitiveDialog();
        void newSpherePrimitiveDialog();
        void newCylinderPrimitiveDialog();
        void newConePrimitiveDialog();

        std::vector<Object*> preOperation(QTreeWidgetItem **);
        void postOperation(QTreeWidgetItem *, Object *);
        void unionOperation();
        void intersectionOperation();
        void differenceOperation();

        void updateActions();
//        void updateTreesVolume(bool);

    private:
        void createWindow();
        int addTreeItem(Object *, QTreeWidgetItem *, bool);
        int updateObjects(std::vector<Object *>);
        void updateOctrees(std::vector<Octree *>);
//        void resetVolumes(QTreeWidgetItem *);
//        void putVolumes(QTreeWidgetItem *);

        QAction *saveObjectsAct;
        QAction *saveObjectsAsAct;
        QAction *saveOctreesAct;
        QAction *openObjectsAct;

        QToolBar *operationToolBar;
        QToolBar *objectsToolBar;
        QPushButton *octreePushButton;
        QToolBar *octreeToolBar;
        QAction *editObjectAct;
        QAction *deleteObjectAct;
        QAction *analysisObjectAct;
        QTreeWidget *tree;

        GLWidget *canvas;
        QList<QTreeWidgetItem *> previousSelected;


        Output output;

        bool inOperation;
        bool staticOctree;
};

#endif
